Repository navigation
fix(yaml): read a tab after a closing quote or an alias as separation - #6939
Conversation
…#6937) The scanners for a quoted scalar and an alias stop just past their closing delimiter, so parse_document_line can be entered mid-line. count_indent took a tab at the cursor for indentation, and the tab-only-line check took the cursor for the start of a blank line, so `a: "b"<TAB>`, `"a"<TAB>`, `- 'x'<TAB>`, `a: &x "b"<TAB>` and `a: *x<TAB>` were refused where yq reads them as separation. Both checks now apply only where the cursor is at the start of a line (at_line_start, which reject_tab_only_line_at_cursor also uses). A tab that starts a line and content after the tab stay refused, as in yq.
Also corrects the count_indent / tab_indents_block_structure comments: Ok(0) no longer implies a tab is absent at the cursor.
CoverageTotal: 93.03% ⚪ 0 pp vs Comparing
🔇 0 ignored region(s), 681 tolerated region(s)
641 more not shown: the full report is in the Touched files absent from every coverage report (2)
These files may contain no executable code or may have been omitted from the coverage run. Patch coveragePatch: 100% (9/9 new lines covered)
Indirect coverage changes🔴 0 lines lost coverage, 🟢 10 lines gained coverage on unchanged code. Indirect changes
|
CoverageTotal: 92.96% ⚪ 0 pp vs Comparing
🔇 0 ignored region(s), 682 tolerated region(s)
642 more not shown: the full report is in the Touched files absent from every coverage report (2)
These files may contain no executable code or may have been omitted from the coverage run. Patch coveragePatch: 100% (9/9 new lines covered)
Indirect coverage changes🔴 0 lines lost coverage, 🟢 10 lines gained coverage on unchanged code. Indirect changes
|
Fixes #6937
Summary
A tab directly after the closing quote of a quoted scalar, or after an alias, in block context (
a: "b"<TAB>,"a"<TAB>,- 'x'<TAB>,a: &x "b"<TAB>,a: *x<TAB>) was a parse error (tab character used for indentation), where yq reads it as separation.The scanners for a quoted scalar and an alias stop just past their closing delimiter, so
parse_document_lineis entered mid-line. Two checks assumed a line start:count_indenttook a tab at the cursor for indentation, andtab_only_line_is_refusedtook the cursor for the start of a blank line. Both now apply only at the start of a line (at_line_start, whichreject_tab_only_line_at_cursorshares). A tab that starts a line, and content after the tab (a: "b"<TAB>c), are still refused, as in yq.Found by a mutation fuzz of the yaml-test-suite inputs against yq v4.53.3 (about 52,000 mutants; the other clusters it found are filed separately).
Test plan
tests/yq_cli/i6937.rs: 19 accepted documents and 8 refused ones, each captured from yq v4.53.3; the accept test fails without the fix (mutation-checked)cargo test --features cli,simd,regex,serde(14,592 passed, 0 failed)cargo clippy --all-targets --all-features -- -D warningscargo clippy --all-targets --features std,simd,serde,cli,regex,bench-runner,large-tests,mmap-tests -- -D warningscargo check --no-default-features,RUSTDOCFLAGS=-D warnings cargo doc,cargo fmt --checkpython3 scripts/changelog.py check